package WaiBao;


import java.util.Arrays;

/**  卢欣宇 20 团支书 黑色背景
 * 张羽  闫玉鑫  李昊东 张耀  赵文博 c 李菲儿 李梦阳
 * 常雨欣 郝敬茹  白佳宇 史丹阳   王卓雅 宋浩然 孟淑贤 刘美琦 孙欣怡 李欣然 师天悦 郭养源 张佳意 刘孟琴
 * 卫子豪  李炳阳 c 贾子轩  杨子城  席佳成 马丹阳
 */
public class LuXIinYu {
    public static void main(String[] args) {
        String[] name = {"张羽 (班长)"," 闫玉鑫 (副班长)", "小李(学习委员)","李昊东(文艺委员)", "张耀", "赵文博", "赵文博", "李菲儿", "李欣然", "师天悦", "郭养源", "王张佳意",
                "李梦阳", "常雨欣", "郝敬茹", "白佳宇", "史丹阳", "王卓雅", "卫子豪", "李炳阳", "李炳阳", "贾子轩", "马丹阳", "杨子城", "席佳成", "大乔", "宋浩然", "刘孟琴",
                "孟淑贤 ", "卢欣宇(团支书)"};//考生本人: 卢欣宇(团支书)
        int[] age = {19, 20, 23, 19, 19, 21, 19, 21, 19, 19, 18, 18, 18, 22, 22, 19,21, 19, 20, 19, 21, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位：考生年龄:20

        double[] tuxiang1 = {84, 79, 70, 83, 77, 70, 78, 89, 81, 94, 91, 87, 85, 79, 61, 68, 99, 99, 90, 80, 82, 91, 95, 65, 75, 74, 94, 64, 80, 96};
        double[] tuxiang2 = {80, 91, 68, 70, 88, 87, 98, 69, 76, 91, 94, 68, 66, 85, 95, 65, 71, 89, 66, 98, 72, 71, 95, 86, 74, 88, 84, 94, 70, 95};
        double[] tuxiang3 = {72, 60, 84, 75, 70, 69, 78, 69, 85, 80, 93, 87, 85, 65, 65, 68, 69, 66, 96, 93, 92, 81, 65, 95, 76, 84, 73, 81, 84, 95};


        double guocheng1 ;//代表每个学生的总分
        double guocheng2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            guocheng1 = tuxiang1[i] +tuxiang2[i] + tuxiang3[i];
//            guocheng2 = (guocheng1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + guocheng1);
//            System.out.println(name[i] + "的平均分为:" +guocheng2);
//        }


        double fushu1 = 0, fushu2= 0;
        double[] xulie  = new double[30];
        for (int i = 0; i < 30; i++) {
            fushu1 = tuxiang1[i] + tuxiang2[i] + tuxiang3[i];
            fushu2 = (fushu1 * 1.0) / 3;
            xulie[i] = fushu2;
        }

        for (int i = 0; i <  xulie.length - 1; i++) {
            for (int j = 0; j <xulie.length - i - 1; j++) {
                if (xulie[j] <xulie[j + 1]) {
                    double tep = xulie[j];
                    xulie[j] =xulie[j + 1];
                    xulie[j + 1] = tep;
                }
            }
        }
        System.out.println("前十名同学的成绩为:");
        for (int i = 0; i < 10; i++) {
            System.out.println( xulie[i]);
        }


        double xuanqu1 = 0, xuanqu2 = 0,xuanqu3 = 0;//计算每门课的平均分
        double try1 = 0, try2 = 0, try3 = 0;//计算每门课标准差
        double miaoshu1 = 0, miaoshu2 = 0,miaoshu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < tuxiang1.length; i++) {
            he += tuxiang1[i];
        }
        xuanqu1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +xuanqu1);
        double Sum = 0;
        for (int i = 0; i <tuxiang2.length; i++) {
            Sum +=tuxiang2[i];
        }
        xuanqu2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + xuanqu2);
        double sum = 0;
        for (int i = 0; i <tuxiang3.length; i++) {
            sum +=tuxiang3[i];
        }
        xuanqu3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + xuanqu3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <tuxiang1.length; i++) {
            c1 += (tuxiang1[i] - xuanqu1) * (tuxiang1[i] - xuanqu1);
        }
        try1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + try1);
        for (int i = 0; i <tuxiang2.length; i++) {
            c2 += (tuxiang2[i] -xuanqu2) * (tuxiang2[i] - xuanqu2);
        }
        try2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" + try2);

        for (int i = 0; i <tuxiang3.length; i++) {
            c3 += (tuxiang3[i] -xuanqu3) * (tuxiang3[i] - xuanqu3);
        }
        try3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +try3);
////
//////
//        Arrays.sort(tuxiang1);
//        Arrays.sort(tuxiang2);
//        Arrays.sort(tuxiang3);
//        miaoshu1 = (tuxiang1[14] + tuxiang2[15]) * 1.0 / 2;
//        miaoshu2 = (tuxiang2[14] +tuxiang2[15]) * 1.0 / 2;
//        miaoshu3 = (tuxiang3[14] + tuxiang3[15]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" + miaoshu1);
//        System.out.println("农业设施设计与制造的中位数为:" +miaoshu2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + miaoshu3);

    }
}
